package com.lch.webdemo.filter;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * filter配置类
 *
 * @author liuchenhui
 * @date 2018/10/22
 * @since
 */
@Configuration
public class FilterConfig {

    /**
     * 可以配置多个filter
     */
    @Bean
    public FilterRegistrationBean globalParamFilter() {
        FilterRegistrationBean registrationBean = new FilterRegistrationBean();
        //设置要初始化的filter
        registrationBean.setFilter(new CommonFilter());
        //设置拦截的路径
        registrationBean.addUrlPatterns("/*");
        //设置filter的执行顺序
//        registrationBean.setOrder();
        //设置初始化参数
//        registrationBean.addInitParameter("param","value");
        return registrationBean;
    }


}
